import store from '@/store'
import {
    saveObjArr,
    getObjArr
} from "@/utils/ruoyi.js"
export default {
    // inserted：被绑定元素插入父节点时调用 (仅保证父节点存在，但不一定已被插入文档中)。
    inserted(el, binding, vnode) {
        const {
            value
        } = binding
        const all_permission = "*:*:*";
        const permissions = getObjArr("permissions")
        if (value && value instanceof Array && value.length > 0) {
            const permissionFlag = value
            const hasPermissions = ["*:*:*"]
            // const hasPermissions = permissions.some(permission => {
            //     return all_permission === permission || permissionFlag.includes(permission)
            // })
            if (!hasPermissions) {
                el.parentNode && el.parentNode.removeChild(el)
                // 或者：el.style.display = 'none'
            }
        } else {
            throw new Error(`请设置操作权限标签值`)
        }
    }
}